/*
 * @Author: qin
 * @Date:   2019-01-25
 * +----------------------------------------------------------------------
 * |  [ 人防系统-专家管理 ]
 * |
 * +----------------------------------------------------------------------
 */
layui.define(['configure', 'configureCom'], function (exports) {
    var configure = layui.configure;
    var configureCom = layui.configureCom;
    var peopleDefense = {
        //通过身份证号模糊查询
        getCardNo: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.PEOPLE_DEFENCE_CARDNO_HTTP, data).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //通过身份证号查询专家信息
        getExpertInfo: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.PEOPLE_DEFENCE_EXPERT_INFO_HTTP, data).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //登录名验重
        loginRepeat: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.postAjax(configure.PEOPLE_DEFENCE_LOGINNAME_REPEAT_HTTP, data).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //保存专家信息。确认聘用
        saveExpertInfo: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.postAjax(configure.PEOPLE_DEFENCE_SAVE_EXPERT_INFO_HTTP, JSON.stringify(data)).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //禁用启用状态切换
        setStatus: function (id) {
            return new Promise(function (resolve, reject) {
                configureCom.putDataAjax(configure.PEOPLE_DEFENCE_SET_STATUS_HTTP, {id: id}).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //解除聘用
        removeExpert: function (id) {
            return new Promise(function (resolve, reject) {
                configureCom.deleteAjax(configure.PEOPLE_DEFENCE_REMOVE_EXPERT_HTTP + '?id=' + id).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //个人云-专家获取聘请列表
        getEmployList: function () {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.PEOPLE_DEFENCE_EMPLOY_LIST_HTTP).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        },
        //个人云-专家同意聘用
        confirmEmploy: function (id) {
            return new Promise(function (resolve, reject) {
                configureCom.putDataAjax(configure.PEOPLE_DEFENCE_CONFIRM_EMPLOY_HTTP, {id: id}).then(function (res) {
                    resolve(res);
                }, function (err) {
                    reject(err);
                });
            });
        }
    };
    exports('peopleDefense', peopleDefense);
});